﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>草稿</title>
    <link href="Scripts/bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css" />
    <link href="Scripts/bootstrap/css/font-awesome.css" rel="stylesheet">
    <link href="Style/skin/css/style.css" rel="stylesheet" type="text/css" />
    <link href="Style/skin/css/animate.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="./Scripts/bootstrap/js/jquery.min.js"></script>
    <script type="text/javascript" src="./Scripts/bootstrap/js/bootstrap.min.js"></script>
    <script src="./Scripts/QueryString.js" type="text/javascript"></script>
    <script src="./Scripts/config.js" type="text/javascript"></script>
    <script src="./Comm/Gener.js" type="text/javascript"></script>
    <script src="Scripts/layui/layui/lay/modules/layer.js" type="text/javascript"></script>
    <!-- 处理多语言 -->
    <script src="Data/lang/load.js" type="text/javascript"></script>
</head>

<body class="gray-bg">

    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="ibox-content">
            <table class="table  table-striped">
                <thead id="theadDiv"></thead>
                <tbody id="Table1">
                </tbody>
            </table>
        </div>
    </div>
  
    <script language="javascript" type="text/javascript">
        function WinOpenIt(url) {
            window.open(url);
            return;

            layer.open({
                skin: 'layer-class',
                type: 2,
                title: '我的草稿',
                area: ['96%', '90%'],
                content: url
            });

        }

        /* ESC Key Down */
        function Esc() {
            if (event.keyCode == 27)
                window.close();
            return true;
        }

        //页面启动函数.
        $(function () {
            var _html = `<th>
                    #
                </th>
                <th>
                    ${window.lang.biaoti}
                </th>
                <th>
                   ${window.lang.liucheng}
                </th>
                <th>
                    ${window.lang.bcrq}
                </th>
                <th>
                    ${window.lang.caozuo}
                </th>
                </tr>`;
            $("#theadDiv").html(_html);
            InitPage();

        });

        //初始化数据.
        function InitPage() {

            var handler = new HttpHandler("BP.WF.HttpHandler.WF");
            handler.AddUrlData();
            var data = handler.DoMethodReturnString("Draft_Init");


            if (data.indexOf('err@') == 0) {
                alert(data);
                return;
            }

            var timeKey = Math.random();
            data = JSON.parse(data);
            var listbox = '';
            //增加处理.
            var idx = 0;
            for (var i = 0; i < data.length; i++) {

                idx++;

                var title = data[i].Title;
                var flowNo = data[i].FK_Flow;
                var flowName = data[i].FlowName;
                var rdt = data[i].RDT;
                var workID = data[i].WorkID;
                var paras = data[i].AtPara; //参数.
                if (paras != '' && paras != null) {
                    paras = paras.replace("'", "\\'");
                    paras = paras.replace('@', '&');
                    paras = paras.replace('@', '&');
                    paras = paras.replace('@', '&');
                    paras = paras.replace('@', '&');
                    paras = paras.replace('@', '&');
                    paras = "1" + paras;
                }

                listbox = "<tr ><td class=Idx >" + idx + "</td>";
                listbox += "<td>" + "<a href=\"javascript:WinOpenIt('MyFlow.htm?FK_Flow=" + flowNo + "&FID=0&WorkID=" + workID + "&IsRead=0&Paras=" + paras + "&T=" + timeKey + "');\" ><img src='./Img/Mail_UnRead.png' border=0 />" + title + "</a></td>";
                listbox += "<td>" + flowName + "</td>";
                listbox += "<td>" + rdt + "</td>";
                listbox += "<td>";
                listbox += "<a href=\"javascript:Delete('" + flowNo + "','" + workID + "')\">删除</a>";
                listbox += "</td>";
                listbox += "</tr>";

                $('#Table1').append(listbox);
            }
        }

        //删除流程.
        function Delete(flowNo, workid) {
            if (window.confirm('您确定要删除草稿吗？') == false)
                return;

            var handler = new HttpHandler("BP.WF.HttpHandler.WF");
            handler.AddPara("WorkID", workid);
            handler.AddPara("FK_Flow", flowNo);
            var data = handler.DoMethodReturnString("Draft_Delete");

            if (data.indexOf('err@') == 0) {
                alert(data);
                return;
            }

            //删除流程.
            alert(data);

            Reload();
        }
    </script>

</body>
</html>
